package com.stx.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.JoinColumn;

@Entity
@Table(name="fc_film")
@SequenceGenerator(name="fi_id",sequenceName="fi_id",initialValue=1,allocationSize=1)

/*
 * 在表关系的一对多 多对多有问题
 * */

public class Film {
	@Id
	@Column(nullable=false)
    @GeneratedValue(generator="fi_id",strategy=GenerationType.SEQUENCE)
	private long fi_id;
	
	@Column(length=100,nullable=false)
	private String fi_name;
	
	private int  fi_state;
	
	@Column(nullable=false)
	private String fi_image;
	
	@Column(nullable=false)
	private String fi_director;
	
	@Column(nullable=false)
	private String fi_screenwriter;
	
	@Column(nullable=false)
    private String fi_actor;
	
	private Date fi_releasetime;
	
	private int fi_times;
	
	@Column(length=100)
	private String fi_alias;
	
	@Column(length=50)
	private String fi_country;
	
	@Column(length=50)
	private String fi_language;
	
	private int fi_comments;
	
	private Date fi_time;
	
	@Column(length=800)
	private String fi_jianjie;
	
	/*
	 * 关联表操作
	 * */
//	@ManyToMany(cascade={CascadeType.PERSIST,CascadeType.MERGE},fetch = FetchType.EAGER)
//	@JoinTable(name="fc_film_type",joinColumns={@JoinColumn(name="fi_id")}
//	          ,inverseJoinColumns={@JoinColumn(name="ty_id")})
//	private Set<Film_type> film_type=new HashSet<Film_type>();
	
	@OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.EAGER,mappedBy="film")
	private Set<Film_type>film_type=new HashSet<Film_type>();
	
	@OneToMany(cascade={CascadeType.MERGE},fetch=FetchType.EAGER,mappedBy="film")
	private Set<Film_image>film_image=new HashSet<Film_image>();
	
	
	@OneToMany(cascade={CascadeType.ALL},fetch=FetchType.EAGER,mappedBy="film")
	private Set<Film_comment>film_comment=new HashSet<Film_comment>();
	
	@OneToMany(cascade={CascadeType.ALL},fetch=FetchType.EAGER,mappedBy="film")
	private Set<User_collection>us_collection=new HashSet<User_collection>();
	/*
	 * get和set方法
	 * */
	
	
	public Set<Film_image> getFilm_image() {
		return film_image;
	}
	public String getFi_language() {
		return fi_language;
	}
	public void setFi_language(String fi_language) {
		this.fi_language = fi_language;
	}
	public Set<User_collection> getUs_collection() {
		return us_collection;
	}
	public void setUs_collection(Set<User_collection> us_collection) {
		this.us_collection = us_collection;
	}
	public void setFilm_image(Set<Film_image> film_image) {
		this.film_image = film_image;
	}
	public Set<Film_comment> getFilm_comment() {
		return film_comment;
	}
	public void setFilm_comment(Set<Film_comment> film_comment) {
		this.film_comment = film_comment;
	}
	public Set<Film_type> getFilm_type() {
		return film_type;
	}
	public void setFilm_type(Set<Film_type> film_type) {
		this.film_type = film_type;
	}
	public long getFi_id() {
		return fi_id;
	}
	public void setFi_id(long fi_id) {
		this.fi_id = fi_id;
	}
	public String getFi_name() {
		return fi_name;
	}
	public void setFi_name(String fi_name) {
		this.fi_name = fi_name;
	}
	public int getFi_state() {
		return fi_state;
	}
	public void setFi_state(int fi_state) {
		this.fi_state = fi_state;
	}
	public String getFi_image() {
		return fi_image;
	}
	public void setFi_image(String fi_image) {
		this.fi_image = fi_image;
	}
	public String getFi_director() {
		return fi_director;
	}
	public void setFi_director(String fi_director) {
		this.fi_director = fi_director;
	}
	public String getFi_screenwriter() {
		return fi_screenwriter;
	}
	public void setFi_screenwriter(String fi_screenwriter) {
		this.fi_screenwriter = fi_screenwriter;
	}
	public String getFi_actor() {
		return fi_actor;
	}
	public void setFi_actor(String fi_actor) {
		this.fi_actor = fi_actor;
	}
	public Date getFi_releasetime() {
		return fi_releasetime;
	}
	public void setFi_releasetime(Date fi_releasetime) {
		this.fi_releasetime = fi_releasetime;
	}
	public int getFi_times() {
		return fi_times;
	}
	public void setFi_times(int fi_times) {
		this.fi_times = fi_times;
	}
	public String getFi_alias() {
		return fi_alias;
	}
	public void setFi_alias(String fi_alias) {
		this.fi_alias = fi_alias;
	}
	public String getFi_country() {
		return fi_country;
	}
	public void setFi_country(String fi_country) {
		this.fi_country = fi_country;
	}
	public int getFi_comments() {
		return fi_comments;
	}
	public void setFi_comments(int fi_comments) {
		this.fi_comments = fi_comments;
	}
	public Date getFi_time() {
		return fi_time;
	}
	public void setFi_time(Date fi_time) {
		this.fi_time = fi_time;
	}
	public String getFi_jianjie() {
		return fi_jianjie;
	}
	public void setFi_jianjie(String fi_jianjie) {
		this.fi_jianjie = fi_jianjie;
	}
	
	
}
